package com.camps.sdk.encrypt;

import com.camps.sdk.common.ExceptionCode;
import com.camps.sdk.entity.SleepTime;
import com.camps.sdk.exception.BaseException;

import javax.activation.CommandMap;

/**
 * @Author ldaoliang
 * @Date create in 10:11 2021/9/1
 * @Description
 */
public class SetSleepModeCommand implements BuildCommand {
    @Override
    public String splicingParameters(String imei, Object params) {
        if(!(params instanceof SleepTime)){
            throw new BaseException(ExceptionCode.PARAMETER_ERROR);
        }
        SleepTime sleepTime = (SleepTime)params;
        String beginTime = sleepTime.getBeginTime();
        String endTime = sleepTime.getEndTime();
        int flag = sleepTime.getOnOff();
        String commandNumber = sleepTime.getCommandNumber();
        StringBuilder sb = new StringBuilder("*WT,");
        sb = sb.append(imei).append(",SLEEPTIME,").append(commandNumber).append(",").append(beginTime).append(",")
                .append(endTime).append(",").append(flag).append("#");
        return sb.toString();
    }
}
